<template>
    <div> 
       <h1>房价添加</h1>
       <table class="table table-bordered">
        <tbody>
            <tr>
                <td align="right">房价计划名称</td>
                <td>
                    <input type="text" v-model="queryinfo.housePriceName"/>
                </td>
            </tr>
            <tr>
                <td align="right">门店</td>
                <td>
                    <select v-model="queryinfo.shopName">
                        <option value="">请选择</option>
                        <option value="北京市昌平区南口店">北京市昌平区南口店</option>
                        <option value="北京市顺义店">北京市顺义店</option>
                        <option value="北京市朝阳店">北京市朝阳店</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td align="right">房型</td>
                <td>
                    <select v-model="queryinfo.typeName">
                        <option value="">请选择</option>
                        <option :value="item.typeName" v-for="item in gethouse">{{ item.typeName }}</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td align="right">房间价格</td>
                <td>
                    <input type="text" v-model="queryinfo.price"/>
                </td>
            </tr>
            <tr>
                <td align="right">房间数量</td>
                <td>
                    <input type="number" v-model="queryinfo.hoomNumber"/>
                </td>
            </tr>
            <tr>
                <td align="right">状态</td>
                <td>
                    <input type="radio" name="stateq" value="启用" v-model="queryinfo.state"/>启用
                    <input type="radio" name="stateq" value="禁用" v-model="queryinfo.state"/>禁用
                </td>
            </tr>
            <tr>
                <td align="right">早餐数量</td>
                <td>
                    <input type="number" v-model="queryinfo.breakfastNum"/>
                </td>
            </tr>
            <tr>
                <td align="right">开始时间</td>
                <td>
                    <input type="date" v-model="queryinfo.startTime"/>
                </td>
            </tr>
            <tr>
                <td align="right">结束时间</td>
                <td>
                    <input type="date" v-model="queryinfo.endTime"/>
                </td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <input type="button" value="添加" class="btn btn-success" @click="ok"/>
                </td>
            </tr>
        </tbody>
       </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import moment from 'moment';
import { ref,reactive,onMounted } from 'vue';
import { useRoute,useRouter } from 'vue-router';
const route=useRoute();
const router=useRouter();

let gethouse:any=ref([])

onMounted(()=>{
    showhouse();
})

const showhouse=()=>
{
    axios
    ({
        url:'/api/House/GetHouse',
        method:'get'
    })
    .then(res=>{
        console.log(res);
        gethouse.value=res.data;
    })
    .catch(err=>{

    })
}

let queryinfo:any=reactive
({
  "housePriceName": "",
  "shopName": "",
  "typeName": "",
  "price": "",
  "hoomNumber": "",
  "state": "启用",
  "breakfastNum": "",
  "startTime": "",
  "endTime": ""
})

const ok=()=>
{
    axios
    ({
        url:'/api/House/HousePriceAdd',
        method:'post',
        data:queryinfo
    })
    .then(res=>{
        if(res.data>0)
        {
          alert("添加成功");
          router.push('housePriceList');
          return;
        }
        else
        {
            alert("添加失败");
            return;
        }
    })
    .catch(err=>{

    })
}



</script>

<style scoped>

</style>